package com.xia.qianke.utils;

import com.xia.qianke.entity.client.Client;
import com.xia.qianke.entity.qk.user.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName DataUtils
 * @Description TODO
 * @Author XJY
 * @Date 2022/7/27 22:55
 * @Version 1.0
 **/
@Component
public class DataUtils {
    @Autowired
    Followers followers;
    //转化两个平台不同的数据格式
    public Sckd changeData(Client client){
        Contacts contacts = new Contacts ();
        String[] phone = new String[]{client.getPhone ()};
        contacts.setMobiles (phone);
        //转化性别：0 未知/ 1 男/ 2 女
        contacts.setSex (Integer.parseInt (client.getSex ()));
        Property[] properties = new Property[]{new Property (24545,0,"年纪",
                client.getAge ().toString ()),new Property (25068,0,"贷款金额",client.getAmount ())};
        contacts.setProperties (properties);
        Contacts[] contact = new Contacts[]{contacts};
        //封装客户星系
        Custm custm = new Custm ();
        custm.setName (client.getName ());
        custm.setAddr (client.getCity ());
        custm.setContacts (contact);

        //封装进线渠道
        SubLblsItem subLblsItem = new SubLblsItem (new Lbl (24326, "申城快贷"));
        SubLblsItem[] subLblsItems = new SubLblsItem[]{subLblsItem};
        ClblsItem clblsItem = new ClblsItem (new Lbl (15405,"渠道"),subLblsItems);
        ClblsItem[] clblsItems = new ClblsItem[]{clblsItem};
        LblDoc lblDoc = new LblDoc (clblsItems);
        custm.setLbl_doc (lblDoc);

        //封装跟进人
        Integer pid = followers.getPid ();
        Followers[] followers = new Followers[]{new Followers (pid)};
        custm.setFollowers (followers);
        //封装跟进人id
        Sckd sckd = new Sckd ();
        sckd.setOp_pid (pid);
        //封装客户信息
        Custm[] custms = new Custm[]{custm};
        sckd.setCustms (custms);
        return sckd;
    }
}
